{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "binary-hospital",
   "metadata": {},
   "source": [
    "# Problem 14.10 Leakage Rate Change in Vacuum Distillation When Lowering the Column Pressure"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "monetary-parks",
   "metadata": {},
   "source": [
    "In sub-atmospheric pressure distillation columns, a vacuum system removes entering air by removing a vapor stream, usually near the top of the column. If air is not removed the pressure will continue to increase, as the air itself won't condense through the condenser (unless it is cryogenic). Air can also pose a fire hazard in some cases. \n",
    "\n",
    "How will the leakage rate into the column change if the pressure of the column is lowered from 0.4 bar to 0.1 bar? Assume the ambient pressure is 1.013 bar."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "electoral-redhead",
   "metadata": {},
   "source": [
    "## Solution\n",
    "\n",
    "Leaks into a column are usually around flanges, through valve or pump packings, inspection or sampling ports, or manholes. \n",
    "\n",
    "There are a variety of empirical correlations that can be used to estimate leakage depending on pressure. The first answer uses one of those. These are not truly `mechanistic`, however. \n",
    "\n",
    "We can also imagine a single hole, and treat the flow as through an orifice. This is the second answer.\n",
    "\n",
    "We can also treat the hole as an isothermal compressible gas flow problem. The third answer uses that."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "danish-detective",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using an emperical correlation, the ratio of air increase is  1.029.\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "from scipy.constants import hour\n",
    "from fluids import *\n",
    "V = 10\n",
    "P1 = 0.4*1e5\n",
    "P2 = 0.1*1e5\n",
    "P_ambient = 101325\n",
    "\n",
    "rho = 1.2\n",
    "\n",
    "D = .8\n",
    "H = 15\n",
    "V = pi/4*D**2*H\n",
    "\n",
    "m1 = vacuum_air_leakage_Seider(V=V, P=P1)*hour\n",
    "m2 = vacuum_air_leakage_Seider(V=V, P=P2)*hour\n",
    "m_ratio = m2/m1\n",
    "print(f'Using an emperical correlation, the ratio of air increase is {m_ratio: .3f}.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "color-staff",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using a flow meter correlation, the ratio of air increase is  1.031.\n"
     ]
    }
   ],
   "source": [
    "# Imagine a 0.1 μm hole in the tower\n",
    "D_hole = 1e-7\n",
    "beta = D_hole/D\n",
    "\n",
    "m1 = differential_pressure_meter_solver(D=D_hole/beta, D2=D_hole, P1=P_ambient, P2=P1, \n",
    "                                        rho=rho, mu=1e-3, k=1.3, meter_type='ISO 5167 orifice', taps='D')\n",
    "m2 = differential_pressure_meter_solver(D=D_hole/beta, D2=D_hole, P1=P_ambient, P2=P2,\n",
    "                                        rho=rho, mu=1e-3, k=1.3, meter_type='ISO 5167 orifice', taps='D')\n",
    "m_ratio = m2/m1\n",
    "print(f'Using a flow meter correlation, the ratio of air increase is {m_ratio: .3f}.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "collected-season",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using isothermal compressible gas flow, the ratio of air increase is  1.081.\n"
     ]
    }
   ],
   "source": [
    "t_hole = 0.008 # 0.8 mm thick wall\n",
    "m1 = isothermal_gas(rho=rho, fd=0.01, P1=P_ambient, P2=P1, L=t_hole, D=D_hole)\n",
    "m2 = isothermal_gas(rho=rho, fd=0.01, P1=P_ambient, P2=P2, L=t_hole, D=D_hole)\n",
    "m_ratio = m2/m1\n",
    "print(f'Using isothermal compressible gas flow, the ratio of air increase is {m_ratio: .3f}.')"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
